﻿using LxBasic;

namespace LxCore
{
    public abstract class VarArrBuider
    {
        public abstract class Base<T>
        {
            public Base(T[] data)
            {
                this.Array = data;
            }
            public T[] Array;
            public virtual T GetCellVar(int cellID)
            {
                throw new NotImplementedException();
            }
            public virtual T GetFaceVar(int faceID)
            {
                throw new NotImplementedException();
            }
        }
        public class Direct<T> : Base<T>, ICellVarArr<T>, IFaceVarArr<T>
        {
            public Direct(T[] innOrBouX) : base(innOrBouX) { }

            public override T GetCellVar(int cellID)
            {
                return Array[cellID];
            }
            public override T GetFaceVar(int faceID)
            {
                return Array[faceID];
            }
        }
        public class InnFaceByAve : Base<double>, IFaceVarArr<double>
        {
            public InnFaceByAve(FvZone zone, double[] xInnOnCell) : base(xInnOnCell)
            {
                this.InnFaces = zone.InnFaces;
            }
            public FvInnFace[] InnFaces;
            public double GetFaceVar(int faceID)
            {
                return InnFaces[faceID].CalAverage(Array);
            }
        }
        public class InnCellByAve : Base<double>, ICellVarArr<double>
        {
            public InnCellByAve(FvZone zone, double[] xInnOnFace) : base(xInnOnFace)
            {
                throw new NotImplementedException();
            }

            public double GetCellVar(int cellID)
            {
                throw new NotImplementedException();
            }
        }
        public class BouCellFaceByInn<T> : Base<T>, ICellVarArr<T>, IFaceVarArr<T>//边界的数据，取内部相连的网格值，当前为了在面上显示MassImbalance
        {
            public BouCellFaceByInn(FvZone zone, T[] xInnOnCell) : base(xInnOnCell)
            {
                this.BouCFaces = zone.BouFaces;
            }
            public FvBouFace[] BouCFaces;
            public override T GetFaceVar(int faceID)
            {
                return Array[BouCFaces[faceID].OSideCell];
            }

            public override T GetCellVar(int cellID)
            {
                return Array[BouCFaces[cellID].OSideCell];
            }
        }

    }
}
//public class Direct_Direct<T> : Base<T>
//{
//    public Direct_Direct(T[] innOrBouX) : base(innOrBouX) { }

//    public override T GetCellVar(int cellID)
//    {
//        return Array[cellID];
//    }
//    public override T GetFaceVar(int faceID)
//    {
//        return Array[faceID];
//    }
//}
//public class Direct_InnFaceAve : Base<double>
//{
//    public Direct_InnFaceAve(FvZone zone, double[] innXOnCell) : base(innXOnCell)
//    {
//        this.InnFaces = zone.InnFaces;
//    }
//    public FvInnFace[] InnFaces;

//    public override double GetCellVar(int cellID)
//    {
//        return Array[cellID];
//    }
//    public override double GetFaceVar(int faceID)
//    {
//        return InnFaces[faceID].CalAverage(Array);
//    }
//}
//public class InnCellAve_Direct : Base<double>
//{
//    public InnCellAve_Direct(FvZone zone, double[] xInnOnFace) : base(xInnOnFace)
//    {
//    }
//    public override double GetCellVar(int cellID)
//    {
//        throw new NotImplementedException();
//    }
//    public override double GetFaceVar(int faceID)
//    {
//        throw new NotImplementedException();
//    }
//}